#ifndef ADXL345_h
#define ADXL345_h

#include "Arduino.h"

/* 
ADXL345 implements an interface to the Analog Devices ADXL345 3-axis accelerometer

This class allows setting of the DATA_FORMAT, POWER_CTL, and BW_RATE registers.
All of these registers provide bit-mapped control of various ADXL345 functions.
The ADXL345 datasheet should be consulted for register settings.

*/


class ADXL345
{
   public:
      ADXL345(void);
      void begin(void);                   // Initializes ADXL functions - default 0x53 I2C addr
      void begin(int i2cAddr);            // Uses i2cAddr for I2C address (for standard 0x1D addr)
                                          // Default settings: measure mode on, full resolution, 16g range
      void get_accel(void);               // Reads the acceleration values
      void set_format(byte theFormat);    // Sets the DATA_FORMAT data register
      int get_format(void);               // Reads the DATA_FORMAT data register
      void set_power_ctl(byte power_ctl); // Sets the POWER_CTL register
      int get_power_ctl(void);            // Reads the POWER_CTL register
      void set_bw_rate(byte bw);          // Sets the BW_RATE register
      int get_bw_rate(void);              // Reads the BW_RATE register
      int x_accel;                        // The x- (y-,z-) acceleration value from the last get_accel()
      int y_accel;                        // Scale factor = 3.9 (+/- 0.4) mg/LSB  @ full resolution
      int z_accel;                        //              = 0.03822 m/s2/LSB

      
   private:
      int _accADDR;    // I2C Bus Address of BMA180 Accelerometer
      byte _aRANG;    // Range Register Word Address
      byte _aACCL;    // Acceleration Register Base
      byte _aBAND;    // BW Register Address
      byte _aPWRC;    // POWER_CTL Register
};

#endif
